#!/bin/env python
# -*- coding:utf-8
"""
@author:xingz
@file:tictactoe_tests.py.py
@time:2021/11/17
"""

from __future__ import annotations
from typing import List
import unittest
from tictactoe.Tictactoe import TTTPiece, TTTBoard
from board import Move
from minmax import minmax, find_best_move


class TTTMinmaxTestCase(unittest.TestCase):
    def test_easy_position(self):
        position = [TTTPiece.X, TTTPiece.O, TTTPiece.E,
                    TTTPiece.E, TTTPiece.X, TTTPiece.E,
                    TTTPiece.E ,TTTPiece.O, TTTPiece.E, ]
        board1 = TTTBoard(position, TTTPiece.X)
        ans: Move = find_best_move(board1)
        self.assertEqual(ans, 8)

    def test_block_position(self):
        position = [TTTPiece.O, TTTPiece.X, TTTPiece.E,
                    TTTPiece.X, TTTPiece.O, TTTPiece.E,
                    TTTPiece.E, TTTPiece.E, TTTPiece.E, ]
        board2 = TTTBoard(position, TTTPiece.X)
        ans: Move = find_best_move(board2)
        self.assertEqual(ans, 8)

    def test_hard_position(self):
        position = [TTTPiece.X, TTTPiece.E, TTTPiece.E,
                    TTTPiece.E, TTTPiece.E, TTTPiece.O,
                    TTTPiece.O, TTTPiece.X, TTTPiece.E, ]
        board3 = TTTBoard(position, TTTPiece.X)
        ans: Move = find_best_move(board3)
        self.assertEqual(ans, 8)


if __name__ == '__main__':
    unittest.main()
